<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>
    选择文件(可多选):
    <input type="file" id="f1" multiple /><br /><br />
    <button type="button" id="btn-submit">上 传</button>
  </div>
</body>
<script>
  function submitUpload() {
    var fd = new FormData();
    var fileList = document.getElementById('f1').files;
    for (var i = 0; i < fileList.length; i++) {
      fd.append('f1', fileList[i]);//支持多文件上传
    }
    fetch('http://localhost:8100/', {
      method: 'POST',
      body: fd
    })
      .then(response => response.json())
      .then(response => {
        console.log(response);
        if (response.fileUrl.length) {
          alert('上传成功');
        }
      })
      .catch(error => console.error('Error:', error));
  }
  document.getElementById('btn-submit').addEventListener('click', submitUpload);
</script>

</html>